<?php

namespace App\Http\Resources;

use App\Constants;
use Illuminate\Http\Resources\Json\JsonResource;

class MenuResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        $arr = [
            'id' => $this->id,
            'parentId' => $this->parent_id,
            'name' => $this->name,
            'sort' => $this->sort,
            'type' => $this->type,
            'routeName' => $this->route_name,
            'routePath' => $this->route_path,
            'path' => $this->route_path,
            'component' => $this->component,
            'perm' => $this->perm,
            'visible' => $this->visible,
            'icon' => $this->icon,
            'redirect' => $this->redirect,
            'keepAlive' => $this->keep_alive,
            'alwaysShow' => $this->always_show,
            'params' => json_decode($this->params,true),
        ];
        return $arr;
    }
}
